﻿/*整理需求文档
* 游戏菜单：
* 展示内容 开始游戏 游戏设置 团队介绍 退出游戏
*        按下不同按键，执行不同操作
* 团队介绍界面：包含不同成员的介绍
*         按下esc键返回到游戏菜单
*游戏设置界面：包含音量调节、音乐开关、难度选择，
*       音量调节；输入数字选中音量后，调节音量大小
*       音乐开关：输入数字选中音乐开关后，切换音乐开关状态
*       难度选择：输入数字选中难度后，切换游戏难度
         按下esc键返回到游戏菜单
* 游戏开始界面：包含游戏开始、游戏结束
* 游戏界面：包含游戏地图、游戏人物、游戏道具，下方具有用时，当前关卡，钥匙，移动次数等信息
*/
#pragma warning(disable: 4996)
#include<stdio.h>
#include<time.h>
#include<stdlib.h>           
#include<Windows.h>
#include<conio.h>
#include<Mmsystem.h>
#pragma comment(lib,"winmm.lib")
#pragma warning(disable: 4996)
// 视图层函数
void yang_setClor(int color);
void menuView();
void gamesetView();
void teamView();
void gameView();
void gameEndView();
void gameQuestionView(int a, char c, int b);
void music_adjust_view();   
void music_adjust_ok_view();
void musicSwitchFunc_view();
void changeGameState_view();
// 服务层函数
void getquestion2();    
void resetMaps();
void initmap();
void initplayer();
void printmap();
void gamesetjudge();
void adjustVolume();
void musicSwitchFunc();
int changeGameState();
void moveplayer();
int judgeMove(int* x, int* y);
int judgepasslevel();
int iswin();
void getGamedegree();
void countSeconds();
void countScore();
void judgeProps();
void teleportProp();
void passThroughWallProp();
void answerProp();
void getqustion1();
//------------------------------------------------------------数据设计----------------------------------------------------
//全局变量声明 有自定义类型
/*下标含义：Easymap[i][x][y],Easymap[0][x][y]表示简单模式下的第一张地图，Easymap[1][x][y]表示简单模式下的第二张地图
元素
使用0代表可以通过
1代表墙壁
2代表起点，同时代表玩家，后面起点随着玩家而动
3代表终点
5代表传送道具
6代表穿墙道具
7代表答题道具
*/
int Easymap[2][8][16] = {
    {   {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        {1,5,1,0,1,0,6,1,0,0,0,0,0,0,0,1},
        {1,0,0,0,0,0,1,1,0,1,1,1,0,1,0,1},
        {1,1,0,1,1,1,0,0,0,1,0,0,0,1,0,1},
        {1,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1},
        {1,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1},
        {1,2,0,0,1,7,0,0,0,1,1,1,0,1,3,1},
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
    },
        {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
            {1,2,0,0,1,0,0,0,0,0,0,0,0,0,0,1},
            {1,0,1,0,1,0,1,0,1,7,1,1,1,0,1,1},
            {1,0,0,5,1,0,0,0,0,0,1,3,1,0,1,1},
            {1,0,1,0,1,1,0,1,0,0,1,0,0,0,0,1},
            {1,0,0,0,1,1,0,6,1,0,1,1,1,0,1,1},
            {1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1},
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
        }


};


//中等难度地图
//下标含义：Mediummap[i][x][y],Mediummap[0][x][y]表示中等模式下的第一张地图，Mediummap[1][x][y]表示中等模式下的第二张地图
int Mediummap[2][10][20] = {
     {  {1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        {1,0,1,0,0,1,0,1,0,0,0,0,0,1,7,1,0,0,0,1},
        {1,0,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,0,1},
        {1,0,0,0,0,1,0,0,0,1,6,0,0,1,0,1,1,1,1,1} ,
        {1,1,0,1,0,0,0,1,1,1,1,0,1,1,0,0,0,0,0,1},
        {1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,1,0,1},
        {1,5,0,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,0,1},
        {1,1,1,0,0,0,1,1,0,1,0,0,0,1,0,1,1,1,0,1},
        {1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1,0,1},
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1}  },
        {
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        {1,2,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
        {1,0,1,1,1,1,0,1,1,1,0,1,0,7,1,0,1,1,0,1},
        {1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1},
        {1,0,1,1,0,0,0,1,0,0,0,0,1,1,0,1,0,6,0,1},
        {1,0,0,1,1,0,1,0,1,0,1,0,0,0,1,3,1,1,0,1},
        {1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,1},
        {1,0,0,1,1,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1},
        {1,0,0,0,0,0,0,5,1,0,0,0,1,1,0,0,0,0,0,1},
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }
};
//困难难度地图    
//下标含义：Hardmap[i][x][y],Hardmap[0][x][y]表示困难模式下的第一张地图，Hardmap[1][x][y]表示困难模式下的第二张地图（缺少各个道具的坐标）
int Hardmap[2][20][40] = {
    { {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
         {1,2,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,7,5,1,1,1,1,1},
         {1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,0,0,1,1},
         {1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,1,1},
         {1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,1,1},
         {1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,1,1,1,0,1,1,0,1,1},
         {1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1},
         {1,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,3,0,1,1,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1},
         {1,0,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,1,1},
         {1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,0,1,1,1,1},
         {1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,0,1,1,1,0,0,0,1,1,1,1,0,0,1,1,1,1,1},
         {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1},
         {1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1},
         {1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1},
         {1,1,1,1,1,1,1,1,1,0,0,0,6,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,1,1,1,1},
         {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}   },

         {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,5,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,7,0,0,0,0,0,1},
{1,0,1,0,1,0,1,0,1,0,0,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1},
{1,1,1,0,0,0,0,1,1,0,1,1,0,0,0,1,1,0,1,0,0,0,0,1,0,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1},
{1,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,0,0,0,1},
{1,1,0,1,0,1,1,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1},
{1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,3,1,1,1,1,1,0,1,0,1,1},
{1,0,1,1,0,1,1,0,1,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,1},
{1,0,0,1,2,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,0,1},
{1,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,1,1,0,0,0,1,0,0,0,1},
{1,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,1,1,1,0,1,0,0,0,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1},
{1,0,1,1,1,0,0,1,0,1,1,1,0,0,0,1,0,0,1,0,1,0,1,1,0,1,0,1,1,1,1,0,1,1,0,1,0,1,0,1},
{1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1},
{1,0,1,1,0,1,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,1,0,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1},
{1,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,1},
{1,0,1,0,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,0,1,1},
{1,0,1,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,6,1,1,0,0,1},
{1,0,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,1,0,1,0,1,0,0,1,1,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}}
};

int Easymap2[2][8][16] = {
    {   {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        {1,5,1,0,1,0,6,1,0,0,0,0,0,0,0,1},
        {1,0,0,0,0,0,1,1,0,1,1,1,0,1,0,1},
        {1,1,0,1,1,1,0,0,0,1,0,0,0,1,0,1},
        {1,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1},
        {1,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1},
        {1,2,0,0,1,7,0,0,0,1,1,1,0,1,3,1},
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
    },
        {
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
            {1,2,0,0,1,0,0,0,0,0,0,0,0,0,0,1},
            {1,0,1,0,1,0,1,0,1,7,1,1,1,0,1,1},
            {1,0,0,5,1,0,0,0,0,0,1,3,1,0,1,1},
            {1,0,1,0,1,1,0,1,0,0,1,0,0,0,0,1},
            {1,0,0,0,1,1,0,6,1,0,1,1,1,0,1,1},
            {1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1},
            {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
        }


};


//中等难度地图
//下标含义：Mediummap[i][x][y],Mediummap[0][x][y]表示中等模式下的第一张地图，Mediummap[1][x][y]表示中等模式下的第二张地图
int Mediummap2[2][10][20] = {
     {  {1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        {1,0,1,0,0,1,0,1,0,0,0,0,0,1,7,1,0,0,0,1},
        {1,0,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,1,0,1},
        {1,0,0,0,0,1,0,0,0,1,6,0,0,1,0,1,1,1,1,1} ,
        {1,1,0,1,0,0,0,1,1,1,1,0,1,1,0,0,0,0,0,1},
        {1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,1,0,1},
        {1,5,0,0,1,0,0,0,0,1,1,1,0,1,0,0,0,1,0,1},
        {1,1,1,0,0,0,1,1,0,1,0,0,0,1,0,1,1,1,0,1},
        {1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1,0,1},
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1}  },
        {
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        {1,2,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
        {1,0,1,1,1,1,0,1,1,1,0,1,0,7,1,0,1,1,0,1},
        {1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1},
        {1,0,1,1,0,0,0,1,0,0,0,0,1,1,0,1,0,6,0,1},
        {1,0,0,1,1,0,1,0,1,0,1,0,0,0,1,3,1,1,0,1},
        {1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,1},
        {1,0,0,1,1,0,1,0,0,1,0,1,0,0,1,0,0,1,0,1},
        {1,0,0,0,0,0,0,5,1,0,0,0,1,1,0,0,0,0,0,1},
        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }
};
//困难难度地图    
//下标含义：Hardmap[i][x][y],Hardmap[0][x][y]表示困难模式下的第一张地图，Hardmap[1][x][y]表示困难模式下的第二张地图（缺少各个道具的坐标）
int Hardmap2[2][20][40] = {
    { {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
         {1,2,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,7,5,1,1,1,1,1},
         {1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0,0,0,1,1,0,0,0,0,1,1},
         {1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,1,1},
         {1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,1,1},
         {1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,1,1,1,1,0,1,1,0,1,1},
         {1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1},
         {1,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,3,0,1,1,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1},
         {1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1},
         {1,0,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,1,1,0,0,1,1,1},
         {1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,0,1,1,1,1},
         {1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,1,0,1,1,1,0,0,0,1,1,1,1,0,0,1,1,1,1,1},
         {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1},
         {1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1},
         {1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1},
         {1,1,1,1,1,1,1,1,1,0,0,0,6,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,1,1,1,1},
         {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}   },

         {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,5,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,7,0,0,0,0,0,1},
{1,0,1,0,1,0,1,0,1,0,0,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1},
{1,1,1,0,0,0,0,1,1,0,1,1,0,0,0,1,1,0,1,0,0,0,0,1,0,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1},
{1,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,0,0,0,1},
{1,1,0,1,0,1,1,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,1,0,1},
{1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,3,1,1,1,1,1,0,1,0,1,1},
{1,0,1,1,0,1,1,0,1,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,1},
{1,0,0,1,2,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,1,1,0,0,1,0,1},
{1,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,1,1,0,0,0,1,0,0,0,1},
{1,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,1,1,1,0,1,0,0,0,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1},
{1,0,1,1,1,0,0,1,0,1,1,1,0,0,0,1,0,0,1,0,1,0,1,1,0,1,0,1,1,1,1,0,1,1,0,1,0,1,0,1},
{1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1},
{1,0,1,1,0,1,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,1,0,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1},
{1,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,1},
{1,0,1,0,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,0,1,1},
{1,0,1,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,6,1,1,0,0,1},
{1,0,1,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,1,0,1,0,1,0,0,1,1,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}}
};

//存储出口坐标，三维数组
//exitPositions[gameState-1][level][0]表示当前难度下当前关卡的出口x坐标
//exitPositions[gameState-1][level][1]表示当前难度下当前关卡的出口y坐标
//数组 int arr[4]={0,1,0,9};arr[0]
int exitPositions[3][2][2] = {
    {{14,6},{11,3}},
{ {18,9},{15,5} },
{ {18,10},{29,6} }
};
int exitPositions2[3][2][2] = {
    {{14,6},{11,3}},
{ {18,9},{15,5} },
{ {18,10},{29,6} }
};
//存储起点坐标，三维数组
//startPositions[gameState-1][level][0]表示当前难度下当前关卡的起点x坐标
// startPositions[gameState-1][level][1]表示当前难度下当前关卡的起点y坐标
int startPositions[3][2][2] = {
    {{1,6},{1,1}},
{ {1,0},{1,1} },
{ {1,1},{4,8} }
};
int startPositions2[3][2][2] = {
    {{1,6},{1,1}},
{ {1,0},{1,1} },
{ {1,1},{4,8} }
};
//存储道具坐标，三维数组,道具具有传送道具、穿墙道具、答题道具
// 道具坐标存储在道具数组中
// 道具数组的下标含义：
// props[gameState-1][level][i][0]表示当前难度下当前关卡第i个道具的x坐标
// props[gameState-1][level][i][1]表示当前难度下当前关卡第i个道具的y坐标
//i:0表示传送道具，1表示穿墙道具，2表示答题道具
int props[3][2][3][2] = {
   {{{1,1},{6,1},{5,6}},{{3,3},{7,5},{9,2}}},
   {{{1,6},{10,3} ,{14,1}},{{7,8},{17,4},{13,2}}},
   {{{34,1},{12,18}, {33,1}},{{16,1},{34,16},{33,1}}}
};
int props2[3][2][3][2] = {
   {{{1,1},{6,1},{5,6}},{{3,3},{7,5},{9,2}}},
   {{{1,6},{10,3} ,{14,1}},{{7,8},{17,4},{13,2}}},
   {{{34,1},{12,18}, {33,1}},{{16,1},{34,16},{33,1}}}
};
//判断游戏状态，1.2.3代表难度，默认为简单
//初始游戏状态为1，表示简单模式
//1代表简单模式，2代表中等模式，3代表困难模式
//在游戏设置中可以修改游戏状态
// 通过修改gameState的值来切换游戏难度
int gameState = 1;
//存储秒数，非核心
int seconds;
//初始时没有拾取到穿墙道具
//0代表没有拾取到穿墙道具，1代表拾取到穿墙道具，最多只有一个穿墙道具
int passCount = 0;  
//存储钥匙数量，初始时没有拾取到钥匙

int key = 0;
//定义一个变量存储当前关卡数，初始为0，
// 0代表第一关，1代表第二关
// 每个难度下有两关，通过修改level的值来切换关卡
int level = 0;
//游戏难度的记录与储存
char gamedegree[100];
//定义一个变量来存储音量，初始为50
int volume = 50;
//定义一个变量来存储音乐开关状态，初始为1，表示音乐开
int musicSwitch = 1;
//运用结构体，存储玩家数据
typedef  struct Player 
{
        int player_x, player_y;//作为玩家坐标
        int moves;//存储移动次数()
        int score;//记录分数
}P;
//定义一个全局变量player，存储玩家数据
//player的x坐标，y坐标，方向，移动次数，分数分别为0
//那么结构体p的成员就变为了全局变量，相当于直接int player_x, player_y, direction, moves, score;
P player = { 0, 0, 0,0};

int direction;
//定义一个变量来记录初始游戏时间，初始为0
int start_time ;



//------------------------------------------------------------数据设计----------------------------------------------------
//-----------------------------------------------------------view-------------------------------------------------------
/*
* 负责人：阳
* 功能：设置控制台字体颜色
* 详细逻辑：使用Windows API函数SetConsoleTextAttribute来设置控制台字体颜色
* 参数color是一个整数，表示颜色属性
*/
void yang_setClor(int color)
{
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, color);
}
/*
* 负责人：阳
* 功能；显示游戏菜单（涉及额外技术，控制台字体颜色变化）
* 详细逻辑：游戏开始时率先调用该函数，显示游戏菜单，
* 根据用户输入的选项，调用不同的view函数
* 可以考虑使用switch语句，根据用户输入的选项，调用不同的view函数
* 再加上一个临时变量choice，存储用户输入的选项
* 显示内容 1.开始游戏 2.游戏设置 3.团队介绍 4.退出游戏
* 具体演示可以参考原型图()scasnf 或者这_getch()函数获取用户输入的选项，
* 可以使用printf函数输出游戏菜单
* 按下不同按键，执行不同操作
*/
void menuView()
{
    initmap();
    initplayer();
	resetMaps();
    start_time = clock();
    system("cls");
    yang_setClor(7); 
    printf("\n");
    printf("╔════════════════════════════╗\n");
    printf("║                            ║\n");
    printf("║       重生之我在迷宫       ║\n");
    printf("║                            ║\n");
    printf("╠════════════════════════════╣\n");
    yang_setClor(10); 
    printf("║       1. 开始游戏          ║\n");
    yang_setClor(11);
    printf("║       2. 游戏设置          ║\n");
    yang_setClor(13); 
    printf("║       3. 团队介绍          ║\n");
    yang_setClor(12);
    printf("║       4. 退出游戏          ║\n");
    yang_setClor(7);
    printf("╚════════════════════════════╝\n");
    printf("\n");
    printf("请输入选项 (1-4)：");
    int choice;
    do {
        choice = _getch();
        printf("%c\n", choice);
        if (choice < '1' || choice > '4') {
            yang_setClor(12);
            printf("输入无效，请重新输入 (1-4)：");
            yang_setClor(7); 
        }
    } while (choice < '1' || choice > '4');
    switch (choice)
    {
    case '1':
        yang_setClor(7);
        system("cls");
        gameView();
        break;
    case '2':
        yang_setClor(3);
        system("cls");
        gamesetView();
        break;
    case '3':
        yang_setClor(1);
        system("cls");
        teamView();
        break;
    case '4':
        yang_setClor(4);
        system("cls");
        printf("确定要退出游戏吗？(Y/N)：");
        char confirm = _getch();
        printf("%c\n", confirm);
        if (confirm == 'Y' || confirm == 'y') {
            exit(0);
        }
        else {
            yang_setClor(7);
            menuView(); 
        }
        break;
    }
}

/*
* 负责人：肌肉kitty
* 功能：显示游戏设置界面（涉及额外技术音乐播放）具体参考原型图
* 详细逻辑：在游戏菜单中选择游戏设置后，调用该函数，显示游戏设置界面
* 接着需要调用gamesetjudge函数，判断游戏设置界面
* 游戏设置界面包括 音量调节、音乐开关、难度选择（changeGameState）,只需要显示选项，不需要实现具体功能（音量与音乐还没有写）
*/
void gamesetView()
{
    getGamedegree();
    system("cls");
    yang_setClor(7);  
    printf("╔════════════════════════╗\n");
    printf("║       游戏设置中心     ║\n");
    printf("╠════════════════════════╣\n");
    yang_setClor(11);     
    printf("║ 1.音效/切换音乐：%-6s║\n", musicSwitch ? "开" : "关");  
    printf("║ 2. 音量： %-6d       ║\n", volume);
    printf("║ 3. 难度： %-6s       ║\n", gamedegree);
    yang_setClor(7);
    printf("╠════════════════════════╣\n");
    yang_setClor(10);  
    printf("║  操作说明：            ║\n");
    printf("║  - 输入数字1-3修改选项 ║\n");
    printf("║  - 按ESC键返回主菜单   ║\n");
    printf("║  -    相较于简单       ║\n");
    printf("║中等与困难具有不同的题目║\n");
    yang_setClor(7);
    printf("╚════════════════════════╝\n");
    yang_setClor(14);  
    printf("\n请输入操作 (1-3) 或按ESC返回: ");
    yang_setClor(7);  

    gamesetjudge();
}
/* 
* 负责人：浮冰
* 功能：显示团队介绍界面
* 详细逻辑：在游戏菜单中选择团队介绍后，调用该函数，显示团队介绍界面
* 团队介绍界面包括不同成员的介绍
* 可以使用printf函数输出团队成员的介绍
* 按下esc键返回到游戏菜单（需要掌握_getch（）函数，不会可以学，不难）
*/
void teamView()
{
    system("cls"); 
    yang_setClor(13); 
    printf("╔════════════════════════════════════╗\n");
    printf("║                                    ║\n");
    printf("║           开发团队成员介绍         ║\n");
    printf("║                                    ║\n");
    printf("╚════════════════════════════════════╝\n");
    yang_setClor(11); 
    printf("╔════════════════════════════════════╗\n");
    yang_setClor(10);
    printf("║  领衔主演：                        ║\n");
    printf("║     黄小快                         ║\n");
    printf("║                                    ║\n");
    printf("║  副领衔主演：                      ║\n");
    printf("║      阳                            ║\n");
    yang_setClor(9); 
    printf("║                                    ║\n");
    printf("║  技术支持：                        ║\n");
    printf("║      秋霞      随便哥      薯条    ║\n");
    yang_setClor(14); 
    printf("║                                    ║\n");
    printf("║  产品设计：                        ║\n");
    printf("║      明远      隐          浮冰    ║\n");
    yang_setClor(12); 
    printf("║                                    ║\n");
    printf("║  素材提供：                        ║\n");
    printf("║      肌肉kitty                     ║\n");
    printf("║                                    ║\n");
    printf("║  学长鼎力支持：                    ║\n");
    printf("║      猫猫      云海        星竹    ║\n");
    printf("║                                    ║\n");
    printf("║  客串：                            ║\n");
    printf("║      harry                         ║\n");
    yang_setClor(11);
    printf("╚════════════════════════════════════╝\n");
    yang_setClor(7);
    printf("\n");
    printf("╔════════════════════════════════════╗\n");
    printf("║         按 ESC 键返回主菜单        ║\n");
    printf("╚════════════════════════════════════╝\n");
    while (1)
    {
        if (_getch() == 27) 
        {
            system("cls");
            break;
        }
    }
    menuView();
}
/*
* 负责人：薯条
* 功能：显示游戏界面
* 详细逻辑：在游戏菜单中选择开始游戏后，调用该函数，显示游戏开始界面
* 调用moveplayer函数，控制玩家移动
* 调用countSeconds函数，计算游戏用时
* 调用countScore函数，计算游戏分数
* 调用judgeProps函数，判断玩家是否拾取道具
* 调用iswin函数，判断玩家是否到达出口
* 如果玩家到达出口，调用gameEndView函数，显示游戏结束界面
* 游戏界面包括
* 游戏地图
* 游戏人物
* 游戏道具
* 下方具有用时，当前关卡，钥匙，移动次数，分数,
* 注意点：问答道具会与玩家位置重合
* 可以使用printf函数输出游戏开始界面
* 按下esc键返回到游戏菜单
*/
void gameView()
{
    while (1)
    {
        countSeconds();    
        judgeProps();         
        if (iswin())
        {
            system("cls");
            gameEndView();    
            while (1)
            {
                if (_getch() == 27) 
                {
                    system("cls");
                    menuView();   
                    return;
                }
            }
        }
        system("cls");
        yang_setClor(13); 
        printf("╔════════════════════════════════════════════════╗\n");
        printf("║                 重生之我在迷宫                 ║\n");
        printf("╚════════════════════════════════════════════════╝\n\n");
        yang_setClor(7);
        printmap();
        printf("\n");
        yang_setClor(11); 
        printf("╔════════════════════════════════════════════════╗\n");
        yang_setClor(10); 
        printf("║  当前分数: %-6d  ", player.score);
        yang_setClor(14); 
        printf("移动次数: %-6d            ║\n", player.moves);
        yang_setClor(9);
        printf("║  钥匙状态: %-6s  ", key == 1 ? "已获得" : "未获得");
        yang_setClor(12); 
        printf("游戏用时: %-6d秒          ║\n", seconds);
        yang_setClor(13); 
        printf("║  当前关卡: ");
        switch (gameState) {
        case 1:
            printf("%d(简单模式)          ", level + 1);
            break;
        case 2:
            printf("%d(中等模式)          ", level + 1);
            break;
        case 3:
            printf("%d(困难模式)          ", level + 1);
            break;
        }
        printf("               ║\n");
        yang_setClor(11); 
        printf("╚════════════════════════════════════════════════╝\n");
        yang_setClor(14); 
        printf("╔═════════════════════════════════════════════════════════════╗\n");
        printf("║ | 穿墙道具可穿单层墙壁，也可破坏双层墙，达到意想不到的效果 |║\n");
        printf("║       |   操作说明: WASD移动  ||  按ESC返回菜单   |         ║\n");
        printf("║    P为玩家|T为传送道具|W为穿墙道具|?为答题道具|E为出口      ║\n");
        printf("║ | 传送道具可传送到任意位置，使用后消失，使用时请谨慎选择 |  ║\n");
        printf("╚═════════════════════════════════════════════════════════════╝\n");
        yang_setClor(7);
        moveplayer();
        countScore();
    }
}
/*
* 负责人：明远
* 功能：显示游戏结束界面
* 详细逻辑：在游戏开始界面中，调用该函数，显示游戏结束界面
* 游戏结束界面包括
* 游戏胜利
* 总移动步数
* 游戏用时
* 游戏难度
* 最终得分
* 按下esc返回到游戏菜单
* 可以使用printf函数输出游戏结束界面
*/
void gameEndView()
{
    system("cls"); 
    yang_setClor(12);
    printf("╔════════════════════════════════════╗\n");
    printf("║                                    ║\n");
    printf("║              游戏胜利              ║\n");
    printf("║                                    ║\n");
    printf("╚════════════════════════════════════╝\n\n");
    yang_setClor(14); 
    printf("╔════════════════════════════════════╗\n");
    yang_setClor(7); 
    printf("║                                    ║\n");
    printf("║        总移动步数：%6d          ║\n", player.moves);
    printf("║                                    ║\n");
    printf("║        全局用时：%6d秒          ║\n", seconds);
    printf("║                                    ║\n");
    printf("║        游戏难度：%s              ║\n", gamedegree);
    printf("║                                    ║\n");
    yang_setClor(10);
    printf("║        最终得分：%6d            ║\n", player.score);
    yang_setClor(7); 
    printf("║                                    ║\n");
    yang_setClor(14); 
    printf("╚════════════════════════════════════╝\n\n");
    yang_setClor(9); 
    printf("╔════════════════════════════════════╗\n");
    yang_setClor(11); 
    printf("║         按 ESC 键返回主菜单        ║\n");
    yang_setClor(9); 
    printf("╚════════════════════════════════════╝\n");
    yang_setClor(7); 
}
/*
* 负责人：小快
* 功能：显示音量调节界面
* 详细逻辑：在游戏设置界面中，选择音量调节后，调用该函数，显示音量调节界面
* 音量调节界面包括
* 当前音量
* 音量条
* 操作指南
* 可以使用printf函数输出音量调节界面
*/
void music_adjust_view()
{
    yang_setClor(13);
    printf("╔════════════════════════════╗\n");
    printf("║                            ║\n");
    printf("║        音量调节中心        ║\n");
    printf("║                            ║\n");
    printf("╚════════════════════════════╝\n\n");
    yang_setClor(11);
    printf("╔════════════════════════════╗\n");
    yang_setClor(10);
    printf("║ 当前音量:  ");
    yang_setClor(14);
    printf("%d%%", volume);
    int spaceCount = 26 - 11 - (volume >= 100 ? 3 : (volume >= 10 ? 2 : 1));
    for (int i = 0; i < spaceCount; i++) printf(" ");
    yang_setClor(10);
    printf("║\n");
    yang_setClor(10);
    printf("║   [");
    yang_setClor(12);
    int barLength = volume / 5;
    for (int i = 0; i < barLength; i++) printf("■");
    yang_setClor(7);
    for (int i = barLength; i < 20; i++) printf("□");
    yang_setClor(10);
    printf("]   ║\n");
    yang_setClor(11);
    printf("╚════════════════════════════╝\n\n");
    yang_setClor(9);
    printf("╔════════════════════════════╗\n");
    yang_setClor(15);
    printf("║  操作指南:                 ║\n");
    printf("║ [A] 减小音量 [D] 增大音量  ║\n");
    printf("║  [ESC] 返回设置菜单        ║\n");
    yang_setClor(9);
    printf("╚════════════════════════════╝\n");
}
/*
* 负责人：小快
* 功能：显示音量调节成功界面
* 详细逻辑：在音量调节界面中，选择音量调节成功后，调用该函数，显示音量调节成功界面
* 音量调节成功界面包括
* 音量设置已保存
* 可以使用printf函数输出音量调节成功界面
* 注意：该界面只需要显示一次，不需要在循环中调用
*/
void music_adjust_ok_view()
{
    yang_setClor(10);
    printf("╔════════════════════════════╗\n");
    printf("║                            ║\n");
    printf("║   音量设置已保存: %d%%      ║\n", volume);
    printf("║                            ║\n");
    printf("╚════════════════════════════╝\n");
    yang_setClor(7);
    printf("\n按任意键返回...");
    _getch();
}
/*
* 负责人：薯条
* 功能：显示音乐开关调节界面
* 详细逻辑：在游戏设置界面中，选择音乐开关调节后，调用该函数，显示音乐开关调节界面
* 音乐开关调节界面包括
* 当前音乐状态
* 操作指南
* 可以使用printf函数输出音乐开关调节界面
* 注意：该界面只需要显示一次，不需要在循环中调用
*/
void musicSwitchFunc_view()
{
    char key;
    int prevState = musicSwitch;
    printf("\n请选择操作: [A]开启音乐  [D]关闭音乐  [ESC]返回\n");
    printf("当前音乐状态: %s\n", musicSwitch ? "开启" : "关闭");
    printf("请输入指令: ");
    key = _getch();
    printf("\n");
    switch (key) {
    case 'a':
    case 'A':
        mciSendStringW(L"close myPlayer", NULL, 0, NULL);
        if (mciSendStringW(L"open ./BGM1.mp3 alias myPlayer type mpegvideo", NULL, 0, NULL) == 0) {
            mciSendStringW(L"play myPlayer repeat", NULL, 0, NULL);
            musicSwitch = 1;
            printf("提示: 音乐已开启\n");
        }
        else {
            printf("提示: 音乐文件打开失败，请检查路径\n");
        }
        break;
    case 'd':
    case 'D':
        mciSendStringW(L"close myPlayer", NULL, 0, NULL);
        musicSwitch = 0;
        printf("提示: 音乐已关闭\n");
        break;
    case 27:
        printf("提示: 返回设置界面\n");
        break;

    default:
        printf("提示: 无效指令，请重新输入\n");
        break;
    }
}
/*
* 负责人：小快
* 功能：显示游戏难度状态选择界面
* 详细逻辑：在游戏设置界面中，选择游戏难度状态选择后，调用该函数，显示游戏难度状态选择界面
* 游戏难度状态选择界面包括
* 当前难度
* 操作指南
* 可以使用printf函数输出游戏难度状态选择界面
*/
void changeGameState_view()
{
    yang_setClor(14);
    printf("╔═══════════════════════════════╗\n");
    printf("║                               ║\n");
    printf("║       游戏难度状态选择        ║\n");
    printf("║                               ║\n");
    printf("╚═══════════════════════════════╝\n\n");
    yang_setClor(11);
    printf("╔═══════════════════════════════╗\n");
    yang_setClor(15);
    printf("║      当前难度:");
    yang_setClor(10);
    printf("%-16s", gamedegree);
    yang_setClor(11);
    printf("║\n");
    printf("╚═══════════════════════════════╝\n\n");
    yang_setClor(9);
    printf("╔═══════════════════════════════╗\n");
    yang_setClor(15);
    printf("║         操作指南              ║\n");
    printf("║                               ║\n");
    yang_setClor(12);
    printf("║   [A]  ");
    yang_setClor(15);
    printf("上一个难度             ║\n");
    printf("║                               ║\n");
    yang_setClor(12);
    printf("║   [D]  ");
    yang_setClor(15);
    printf("下一个难度             ║\n");
    printf("║                               ║\n");
    yang_setClor(12);
    printf("║   [ESC]  ");
    yang_setClor(15);
    printf("返回设置菜单         ║\n");
    yang_setClor(9);
    printf("╚═══════════════════════════════╝\n");
}
/*
* 负责人：秋霞
* 功能：显示游戏问答挑战界面
* 详细逻辑：在游戏中遇到问答道具时，调用该函数，显示游戏问答挑战界面
* 游戏问答挑战界面包括
* 题目
* 提示
* 操作指南
* 可以使用printf函数输出游戏问答挑战界面
*/
void gameQuestionView(int a,char c,int b)
{
    yang_setClor(14);
    printf("╔════════════════════════════╗\n");
    printf("║                            ║\n");
    printf("║          问答挑战          ║\n");
    printf("║                            ║\n");
    printf("╚════════════════════════════╝\n");
    yang_setClor(11);
    printf("╔════════════════════════════╗\n");
    yang_setClor(7);
    printf("║  请回答以下问题，获得钥匙  ║\n");
    printf("║                            ║\n");
    yang_setClor(10);
    printf("║  题目： %d %c %d = ?          ║\n", a,c, b);
    printf("║                            ║\n");
    yang_setClor(9);
    printf("║  提示：输入数字后按回车    ║\n");
    printf("║  答对获得钥匙，答错可重试  ║\n");
    yang_setClor(11);
    printf("╚════════════════════════════╝\n\n");
}
//------------------------------------------------------view------------------------------------------------------------
//-----------------------------------------------------service----------------------------------------------------------
/*
* 负责人：随便哥
* 功能：初始化游戏
* 详细逻辑：在游戏开始前，调用该函数，初始化游戏相关参数（不需要在循环中）
* 初始化的规则：
* (哪些变量需要初始化)
* seconds初始化为0
* passCount初始化为0
* key初始化为0
* level初始化为0
* 实现思路：直接将上述变量赋值为0即可
*/
void initmap()
{
    seconds = 0;
    passCount = 0;
    key = 0;
    level = 0;
}
/*
* 负责人：随便哥
* 功能：初始化玩家数据
* 详细逻辑：在游戏开始前，调用该函数，初始化玩家数据
* 初始化的规则：
* player的x坐标初始化为startPositions[gameState-1][level][0]
* player的y坐标初始化为startPositions[gameState-1][level][1]
* player的moves初始化为0
* player的score初始化为0
* 实现思路：直接将上述变量赋值即可
* 注意：player的x坐标和y坐标需要根据当前游戏状态和关卡数来获取
* exitPositions[gameState-1][level][0]和exitPositions[gameState-1][level][1]分别表示当前游戏状态下当前关卡的出口坐标\
* startPositions[gameState-1][level][0]和startPositions[gameState-1][level][1]分别表示当前游戏状态下当前关卡的起点坐标
* 该函数只需要在游戏开始前调用一次即可，不需要在循环中调用
* 结构体P中有player_x, player_y, direction, moves, score成员变量
*/
void initplayer()
{
    player.player_x = startPositions[gameState - 1][level][0];
    player.player_y = startPositions[gameState - 1][level][1];

    player.moves = 0;
    player.score = 0;
}
/*
* 负责人：小快
* 功能：备份地图，初始时将当前关卡的地图备份到一个数组中，后续重新加载地图时使用
* 详细逻辑：在游戏开始前，调用该函数，备份当前关卡的地图
*/
void resetMaps() {
    // 从备份复制回原地图
    memcpy(Easymap, Easymap2, sizeof(Easymap));
    memcpy(Mediummap, Mediummap2, sizeof(Mediummap));
    memcpy(Hardmap, Hardmap2, sizeof(Hardmap));

	// 备份起点和出口坐标
    memcpy(exitPositions, exitPositions2, sizeof(exitPositions));
    memcpy(startPositions, startPositions2, sizeof(startPositions));
    
    // 备份道具坐标
	memcpy(props, props2, sizeof(props));

}
/*
 * 负责人：隐
 * 功能：打印地图（浮冰，阳 隐 肌肉kitty）
 * 详细逻辑：根据当前游戏状态(难度)，打印不同难度下的地图
 * 问答道具会与玩家位置重合，要将玩家打印在最上层
 * 注意这个地方涉及到不同元素的定制
 * 例如道具，墙壁，起点，终点等
 * 需要注意按照原型图进行打印
 * level表示当前关卡数
 * gameState表示当前游戏状态（难度）
 * 
 * 选取相应难度下的地图进行打印
 */
void printmap()
{
    if (gameState == 1) // 简单难度地图
    {
        for (int i = 0; i < 8; i++) // 行范围：0-7
        {
            for (int j = 0; j < 16; j++) // 列范围：0-15
            {
                // 优先显示当前关卡的玩家位置
                if (i == player.player_y && j == player.player_x)
                {
                    printf("P");
                }
                // 否则显示地图原有元素
                else if (Easymap[level][i][j] == 0)
                    printf(" ");
                else if (Easymap[level][i][j] == 1)
                    printf("#");
                else if (Easymap[level][i][j] == 3)
                    printf("E");
                else if (Easymap[level][i][j] == 5)
                    printf("T");
                else if (Easymap[level][i][j] == 6)
                    printf("W");
                else if (Easymap[level][i][j] == 7)
                    printf("?");
            }
            printf("\n");
        }
    }
    else if (gameState == 2) // 中等难度地图
    {
        for (int i = 0; i < 10; i++) // 行范围：0-9
        {
            for (int j = 0; j < 20; j++) // 列范围：0-19
            {
                if (i == player.player_y && j == player.player_x)
                {
                    printf("P");
                }
                else if (Mediummap[level][i][j] == 0)
                    printf(" ");
                else if (Mediummap[level][i][j] == 1)
                    printf("#");
                else if (Mediummap[level][i][j] == 3)
                    printf("E");
                else if (Mediummap[level][i][j] == 5)
                    printf("T");
                else if (Mediummap[level][i][j] == 6)
                    printf("W");
                else if (Mediummap[level][i][j] == 7)
                    printf("?");
            }
            printf("\n");
        }
    }
    else if (gameState == 3) // 困难难度地图
    {
        for (int i = 0; i < 20; i++) // 行范围：0-19
        {
            for (int j = 0; j < 40; j++) // 列范围：0-39
            {
                if (i == player.player_y && j == player.player_x)
                {
                    printf("P");
                }
                else if (Hardmap[level][i][j] == 0)
                    printf(" ");
                else if (Hardmap[level][i][j] == 1)
                    printf("#");
                else if (Hardmap[level][i][j] == 3)
                    printf("E");
                else if (Hardmap[level][i][j] == 5)
                    printf("T");
                else if (Hardmap[level][i][j] == 6)
                    printf("W");
                else if (Hardmap[level][i][j] == 7)
                    printf("?");
            }
            printf("\n");
        }
    }
}
/*
* 负责人：秋霞
* 功能：实现游戏设置界面判断
* 详细逻辑：在游戏设置界面中，调用该函数，根据用户输入的选项，判断游戏设置界面
* 游戏设置界面包括 音量调节、音乐开关、难度选择（changeGameState）
* 1代表音量调节，2代表音乐开关，3代表难度选择
* 使用_getch()函数获取用户输入的选项
* 如果用户输入的选项为1，调用音量调节函数（adjustVolume）
* 如果用户输入的选项为2，调用音乐开关函数(musicSwitchFunc)
* 如果用户输入的选项为3，调用难度选择函数（changeGameState）
*/
void gamesetjudge()
{
    int a = _getch();
    switch (a) {
    case 50:
        adjustVolume();
        break;
    case 49:
        musicSwitchFunc();
        break;
    case 51:
        changeGameState();
        break;
    default:
        system("cls");
        menuView();
    }
}
/*
* 负责人：薯条
* 功能：实现音量调节
* 详细逻辑：在游戏设置界面中，调用该函数，实现音量调节
* 音量调节的规则：
* 使用ad这两个按键来调节音量
* 1.按下a键，音量减小
* 2.按下d键，音量增大
* 音量范围为0-100
* 通过修改音量的值来调节音量，音量为全局变量volume
* 音量的初始值为50
* 音量的值为0-100
* 音量调节函数只需要在游戏设置界面中调用一次即可，不需要在循环中调用
*/
void adjustVolume()
{
    // 检查音乐是否开启
    if (musicSwitch == 0)
    {
        system("cls");
        yang_setClor(12); // 红色提示
        printf("╔════════════════════════════╗\n");
        printf("║                            ║\n");
        printf("║   请先开启音乐再调节音量！  ║\n");
        printf("║                            ║\n");
        printf("╚════════════════════════════╝\n");
        yang_setClor(7);
        printf("\n按任意键返回设置...");
        _getch();
        gamesetView();
        return;
    }
    char key;
    int prevVolume = volume; 
    while (1)
    {
        system("cls");
        music_adjust_view();
        key = _getch();
        switch (key)
        {
        case 'a':
        case 'A':
            if (volume > 0)
            {
                volume--;
                char cmd[64];
                sprintf(cmd, "setaudio myPlayer volume to %d", volume * 10);
                mciSendString(cmd, NULL, 0, NULL);
            }
            break;
        case 'd':
        case 'D':
            if (volume < 100)
            {
                volume++;
                char cmd[64];
                sprintf(cmd, "setaudio myPlayer volume to %d", volume * 10);
                mciSendString(cmd, NULL, 0, NULL);
            }
            break;
        case 27: 
            system("cls");
            music_adjust_ok_view();
            gamesetView(); 
            return;
        default:
            break;
        }
    }
}
/*
* 负责人：薯条
* 功能：实现音乐开关
* 详细逻辑：在游戏设置界面中，调用该函数，实现音乐开关
* 音乐开关的规则：
* 1.按下a键，音乐开关打开
* 2.按下d键，音乐开关关闭
* 音乐开关的初始状态为打开
* 音乐开关的状态可以用一个全局变量来表示
*/
void musicSwitchFunc()
{
	musicSwitchFunc_view(); 
    printf("按任意键返回设置界面...");
    _getch();
    system("cls"); 
    gamesetView();
}
/*
* 负责人：秋霞
* 功能：改变游戏状态
* 详细逻辑：在游戏设置界面中，选择不同难度，调用该函数，改变游戏状态
* 使用ad这两个按键来切换游戏难度
* 通过修改gameState的值来切换游戏难度，gameState为全局变量
* 1代表简单模式，2代表中等模式，3代表困难模式
*/
int changeGameState() {
    while (1) {
        getGamedegree();
        system("cls");
        changeGameState_view();
        int ret = _getch();
        switch (ret) {
        case 'D':
        case 'd':
            gameState = (gameState + 1) % 4;
            break;
        case 'A':
        case 'a':
            gameState = (gameState - 1 + 4) % 4;
            break;
        case 27: 
            system("cls");
            menuView();
            break;
        default:
            break;
        }
    }
}
/*
* 负责人：明远
* 功能：实现玩家移动
* 详细逻辑：在游戏开始界面中，调用该函数，实现玩家移动
* 玩家移动的规则：
* 1.玩家可以通过wsad键移动，调动getPlayerDirection函数获取玩家移动方向
* 2.玩家移动时，调用judgeMove函数，判断玩家移动  是否合法
* 3.如果玩家移动合法，更新玩家坐标,moves加1
* 调用全局变量P，存储玩家数据
*/
    void moveplayer()
    {
        int X = player.player_x;
        int Y = player.player_y;
        char move = _getch();
        direction = move;
        switch (move) 
        {
        case 'w':
        case'W':
            Y--;
            break;
        case 's':
        case'S':
            Y++;
            break;
        case'A':
        case 'a':
            X--;
            break;
        case 'd':
        case'D':
            X++;
            break;
        case 27:
            system("cls");
            menuView();
            break;
        }
        if (judgeMove(&X, &Y))
        {
            if (gameState == 1)
            {
                Easymap[level][player.player_y][player.player_x] = 0;
                Easymap[level][Y][X] = 2;
            }
            else if (gameState == 2)
            {
                Mediummap[level][player.player_y][player.player_x] = 0;
                Mediummap[level][Y][X] = 2;
            }
            else if (gameState == 3)
            {
                Hardmap[level][player.player_y][player.player_x] = 0;
                Hardmap[level][Y][X] = 2;
            }
            player.player_x = X;
            player.player_y = Y;
            player.moves++;
        }

    }


/*
* 负责人：明远
* 功能：判断玩家移动是否合法
* 详细逻辑：在玩家移动时，调用该函数，判断玩家移动是否合法
* 判断玩家移动是否合法的规则：
* 1.玩家不能移动到墙壁上
（注意点：关于墙壁
*1.地图中只具有单层墙壁
*2.判断条件是需要加上passCount!=0的判断，便于后续穿墙道具功能的实现）
*具体可以参考可行性分析，也可以问组长
* 2.玩家不能移动到地图边界外
* 3.玩家可以移动到空地上
* 4.玩家可以移动到终点上
* 5.玩家可以移动到道具上
* 书写逻辑：获得玩家移动后的坐标，判断该坐标是否符合上述规则，
* 如果符合规则，返回1，表示移动合法
否则返回0，表示移动不合法
*/
    int judgeMove(int* x, int* y)
    {
         Sleep(10);
		 Sleep(10);
         Sleep(10);
         Sleep(10);
        if (gameState == 1)
        {
            if (Easymap[level][*y][*x] == 1 && passCount == 0)
            {
                return 0; //玩家不能移动到墙壁上
            }
            if (Easymap[level][*y][*x] == 1 && passCount == 1)
            {
                passCount--;
                switch (direction)
                {
                case 87:
                case 119:
                    (*y)--;
                    break;
                case 115:
                case 83:
                    (*y)++;
                    break;
                case 65:
                case 97:
                    (*x)--;
                    break;
                case 68:
                case 100:
                    (*x)++;//cuowu 错误
                    break;
                }
                return 1; //玩家可以穿过单层墙壁
            }

            if ((*x) < 0 || (*y) < 0 || (*x) > 16 || (*y) > 8)
            {
                return 0; //玩家不能移动到地图边界外
            }
            return 1; //玩家可以移动到空地上
        }
        else if (gameState == 2)
        {
            if (Mediummap[level][*y][*x] == 1 && passCount == 0)
            {
                return 0; //玩家不能移动到墙壁上
            }
            if (Mediummap[level][*y][*x] == 1 && passCount == 1)
            {
                passCount--;
                switch (direction)
                {
                case 87:
                case 119:
                    (*y)--;
                    break;
                case 115:
                case 83:
                    (*y)++;
                    break;
                case 65:
                case 97:
                    (*x)--;
                    break;
                case 68:
                case 100:
                    (*x)++;//cuowu 错误
                    break;
                }
                return 1; //玩家可以穿过单层墙壁
            }
            if ((*x) < 0 || (*y) < 0 || (*x) > 20 || (*y) > 10)
            {
                return 0; //玩家不能移动到地图边界外
            }
            return 1; //玩家可以移动到空地上
        }
        else if (gameState == 3)
        {
            if (Hardmap[level][*y][*x] == 1 && passCount == 0)
            {
                return 0; //玩家不能移动到墙壁上
            }
            if (Hardmap[level][*y][*x] == 1 && passCount == 1)
            {
                passCount--;
                switch (direction)
                {
                case 87:
                case 119:
                    (*y)--;
                    break;
                case 115:
                case 83:
                    (*y)++;
                    break;
                case 65:
                case 97:
                    (*x)--;
                    break;
                case 68:
                case 100:
                    (*x)++;//cuowu 错误
                    break;
                }
                return 1; //玩家可以穿过单层墙壁
            }
            if ((*x) < 0 || (*y) < 0 || (*x) > 40 || (*y) > 20)
            {
                return 0; //玩家不能移动到地图边界外
            }
            return 1; //玩家可以移动到空地上


        }
    }
/*
* 负责人：隐
* 功能：判断玩家是否通过关卡 
* 详细逻辑：在玩家移动后时，调用该函数，判断玩家是否通过关卡
* 判断玩家是否通过关卡的规则：
* 1.玩家必须到达终点(玩家的坐标与终点坐标相同)
* 2.玩家必须拾取到钥匙(玩家的key大于0)
* 如果满足上述条件，返回1，表示通过关卡，否则返回0，表示未通过关卡
*/
    int judgepasslevel()
    {
        return (player.player_x == exitPositions[gameState - 1][level][0]
            && player.player_y == exitPositions[gameState - 1][level][1]
            && key == 1);
    }
/*
* 负责人：肌肉kitty
* 功能：实现判断是否胜利功能
* 详细逻辑：在玩家通过关卡时，调用该函数，判断是否胜利
* 判断是否胜利的规则：
* 1.如果当前关卡数等于2，（即level==2）并且玩家持有钥匙（key==1），返回1，表示胜利
* 2.否则返回0，表示未胜利
*/
 int iswin()
 {
     
     if ((level == 2))
     {
         return 1;

     }
	 return 0; // 未胜利
 }
/*
* 负责人：阳
* 功能：实现根据gamestate返回游戏难度中文的功能
* 详细逻辑：在游戏设置界面中，调用该函数，根据gamestate返回游戏难度中文
* gamestate为全局变量
* 1.如果gamestate等于1，利用指针相关知识，将‘简单”赋值给gamedegree
* 2.如果gamestate等于2，将“中等”赋值给gamedegree
* 3.如果gamestate等于3，将“困难”赋值给gamedegree
* 返回值为字符串类型
* 如果gamestate不等于1，2，3，返回"未知"
*/
void getGamedegree()
{
    if (gameState == 1)
    {
        strcpy(gamedegree, "简单");
    }
    else if (gameState == 2)
    {
        strcpy(gamedegree, "中等");
    }
    else if (gameState == 3)
    {
        strcpy(gamedegree, "困难");
    }
    else
        strcpy(gamedegree, "错误");
}
/*
* 负责人：小快
* 功能：实现计时功能
* 详细逻辑：在游戏开始时，调用该函数，计时
* 计时的规则：
* 可以使用time函数获取当前时间，计算时间差
* 结构体P中有seconds成员变量
*/
void countSeconds()
{
    // 计算当前用时（核心计时逻辑）
    clock_t current_time = clock();
    // 转换为秒（CLOCKS_PER_SEC 是每秒的时钟周期数）
    seconds = (int)((current_time - start_time) / CLOCKS_PER_SEC);
}
/*
* 负责人：肌肉kitty
* 功能：实现计算分数功能
* 详细逻辑：在游戏结束时，调用该函数，计算分数
* 计算分数的规则：
* 运用步数，难度，时间来计算分数
* 具体公式由肌肉kitty提供 结构体P中有score成员变量
*/
void countScore()
{
    int difficultyWeight;
    switch (gameState) {
    case 1:  // 简单难度
        difficultyWeight = 2;
        break;
    case 2:  // 中等难度
        difficultyWeight = 3;
        break;
    case 3:  // 困难难度
        difficultyWeight = 4;
        break;
    default:
        difficultyWeight = 2;
        break;
    }
    int baseScore = 1000 + (player.moves * 10 > 100 ? 0 : 100 - player.moves * 10);
    float timeFactor = (seconds > 60 ? 1.5f : (float)seconds / 60 * 1.5f);
    player.score = (int)(baseScore * difficultyWeight * timeFactor);
}
/*
* 负责人：随便哥
* 功能：实现道具功能
* 详细逻辑：在玩家移动后，调用该函数，实现道具判断
* 道具功能的规则：
* 1.如果玩家移动到传送道具上，调用传送道具函数(teleportProps)
* 2.如果玩家移动到穿墙道具上，调用穿墙道具函数（passThroughWallProp）
* 3.如果玩家移动到答题道具上，调用答题道具函数（）
* 4.如果玩家没有移动到道具上，不做任何操作
* 关键是玩家位置与道具位置的判断，建议使用地图数组的值来判断、
* 例如：Easymap[level][player.player_x][player.player_y] == 5
* 表示玩家移动到传送道具上
*/
void judgeProps()
{
    if (player.player_x == props[gameState - 1][level][0][0] && player.player_y == props[gameState - 1][level][0][1])
    {
        teleportProp();
    }
    else if (player.player_x == props[gameState - 1][level][2][0] && player.player_y == props[gameState - 1][level][2][1])
    {
        answerProp();
    }
    else if (player.player_x == props[gameState - 1][level][1][0] && player.player_y == props[gameState - 1][level][1][1])
    {
        passThroughWallProp();
    }
    else if(player.player_x == exitPositions[gameState-1][level][0] && player.player_y == exitPositions[gameState-1][level][1])
    {
        if (key == 1)
        {
			player.score += 500; // 通过关卡奖励500分
            level++;
            key--;
			player.player_x = startPositions[gameState - 1][level][0];
			player.player_y = startPositions[gameState - 1][level][1];
            
        }
        
    }

}
/*
* 负责人：秋霞
* 功能：实现传送道具功能
* 详细逻辑：在玩家移动到传送道具上时，调用该函数，实现传送道具功能
* 传送道具功能的规则：
* 1.如果玩家移动到传送道具上，随机生成一个有效地图位置
* 2.将玩家移动到该位置（注意：该位置不能为终点，也不能是其他道具点）
* 3.将传送道具从地图上移除
* 4.可以使用rand函数生成随机数，生成一个有效地图位置
*/
void teleportProp()
{
    srand((unsigned int)time(NULL));
    int x = -1, y = -1;
    int maxX = 0, maxY = 0;
    int** map = NULL;
    if (gameState == 1) { maxX = 16; maxY = 8; map = (int**)Easymap[level]; }
    else if (gameState == 2) { maxX = 20; maxY = 10; map = (int**)Mediummap[level]; }
    else if (gameState == 3) { maxX = 40; maxY = 20; map = (int**)Hardmap[level]; }
    // 只要map有效
    if (map) {
        int tryCount = 0;
        while (1) {
            x = rand() % maxX;
            y = rand() % maxY;
            int v = 0;
            if (gameState == 1) v = Easymap[level][y][x];
            else if (gameState == 2) v = Mediummap[level][y][x];
            else if (gameState == 3) v = Hardmap[level][y][x];
            // 不能传送到墙、终点、道具
            if (v == 0) break;
            if (++tryCount > 100) break; // 防止死循环
        }
        // 移除传送道具
        int px = props[gameState - 1][level][0][0];
        int py = props[gameState - 1][level][0][1];
        if (px >= 0 && py >= 0 && px < maxX && py < maxY) {
            if (gameState == 1) Easymap[level][py][px] = 0;
            else if (gameState == 2) Mediummap[level][py][px] = 0;
            else if (gameState == 3) Hardmap[level][py][px] = 0;
        }
        props[gameState - 1][level][0][0] = -1;
        props[gameState - 1][level][0][1] = -1;
        // 清除原玩家位置
        if (gameState == 1) Easymap[level][player.player_y][player.player_x] = 0;
        else if (gameState == 2) Mediummap[level][player.player_y][player.player_x] = 0;
        else if (gameState == 3) Hardmap[level][player.player_y][player.player_x] = 0;
        // 更新玩家位置
        player.player_x = x;
        player.player_y = y;
        if (gameState == 1) Easymap[level][y][x] = 2;
        else if (gameState == 2) Mediummap[level][y][x] = 2;
        else if (gameState == 3) Hardmap[level][y][x] = 2;
    }
}
/*
* 负责人：小快
* 功能：实现穿墙道具功能
* 详细逻辑：在玩家移动到穿墙道具上时，调用该函数，实现穿墙道具功能
* 穿墙道具功能的规则：
* 1.如果玩家移动到穿墙道具上，passCount加1
* 2.将穿墙道具从地图上移除
* 注意：passCount是一个全局变量，初始值为0
* 穿墙道具的作用是允许玩家穿过墙壁
* 如果玩家移动到墙壁上，判断passCount是否大于0,
* 如果大于0，允许玩家穿过墙壁，passCount减1
* 如果小于等于0，不允许玩家穿过墙壁
* 注意：穿墙道具是一次性道具，使用后会被移除（改变主意了，突然想到一直穿墙有点逆天,）
* passCount表示玩家当前拥有的穿墙道具数量0与1
* 可以使用一个全局变量passCount来记录穿墙道具的数量
* passCount的初始值为0
*/
void passThroughWallProp()
{
    passCount++;
    props[gameState - 1][level][1][0] = -1;//将穿墙道具从地图上移除
    props[gameState - 1][level][1][1] = -1;
}
/*
* 负责人：小快
* 功能：实现答题道具功能
* 详细逻辑：在玩家移动到答题道具上时，调用该函数，实现答题道具功能
* 答题道具功能的规则：
* 1.如果玩家移动到答题道具上，调用游戏问答界面函数（gameQuestionView）
*    调用getquestion函数，获取问题
* 2.在游戏问答界面中，玩家可以输入答案
* 3.如果玩家答对了，key值+1，表示答题成功，清除答题道具
* 4.如果玩家答错了，key值为0，表示答题失败，不清楚答题道具
*/
void answerProp()
{
	system("cls");
    if (gameState == 1)
    {
        getqustion1();
    }
    else if (gameState != 1)
    {
        getquestion2();
    }

    if (gameState == 1)
    {
        Easymap[level][props[gameState - 1][level][2][1]][props[gameState - 1][level][2][0]] = 0;
    }
    else if (gameState == 2)
    {
        Mediummap[level][props[gameState - 1][level][2][1]][props[gameState - 1][level][2][0]] = 0;
    }
    else if (gameState == 3)
    {
        Hardmap[level][props[gameState - 1][level][2][1]][props[gameState - 1][level][2][0]] = 0;
    }
    props[gameState - 1][level][2][1] = -1;
    props[gameState - 1][level][2][0] = -1;

}

/*
* 负责人：秋霞
* 功能：获取问题
* 详细逻辑：在玩家移动到答题道具上时，调用该函数，获取问题
* 问题的规则： （待填）（可行性分析中有）
* 1.利用随机数生成三个数字
* 2.其中两个作为运算数字
* 3.第三作为运算符号
* 4定义一个数组存储运算符号
* 例如char operators[] = {'+', '-', '*', '/'};
* 而第三个数字作为下标索引，获取运算符号
* 5.根据运算符号进行运算，得到答案
* 6.将问题，选项，答案存储在相应的变量中
* 7.返回问题，选项，答案
* 注意：该函数只需要在玩家移动到答题道具上时调用一次即可，不需要在循环中调用
* 8打印问题
* 9用户输入答案
* 10判断答案与输入，是否正确
* 直到答对才能出循环
* 返回1
* 
*/
void getqustion1()
{
    int num1, num2, op_index, correct_answer;
    char operators[] = { '+', '-', '*' };
    srand((unsigned int)time(NULL));
    num1 = rand() % 10 + 1; 
    num2 = rand() % 10 + 1;  
    op_index = rand() % 3;   
    if (operators[op_index] == '-') {
        if (num1 < num2) {
            int temp = num1;
            num1 = num2;
            num2 = temp;
        }
    }
    switch (operators[op_index]) {
    case '+': correct_answer = num1 + num2; break;
    case '-': correct_answer = num1 - num2; break;
    case '*': correct_answer = num1 * num2; break;
    }
    system("cls");
    gameQuestionView(num1, operators[op_index],num2);
    int answer;
    while (1) {
        yang_setClor(15);  
        printf("请输入答案：");
        if (scanf_s("%d", &answer) != 1) {
            yang_setClor(12);  
            printf("输入错误！请输入数字\n");
            while (getchar() != '\n');  
            continue;
        }
        if (answer == correct_answer) {
            yang_setClor(10); 
            printf("\n╔════════════════════════════╗\n");
            printf("║  回答正确！获得钥匙啦～    ║\n");
            printf("╚════════════════════════════╝\n");
            key++;  
            break;
        }
        else {
            yang_setClor(12); 
            printf("\n╔════════════════════════════╗\n");
            printf("║   回答错误！再试一次吧～   ║\n");
            printf("║       按 任意键 重试      ║\n");
            printf("╚════════════════════════════╝\n");
            char retry = _getch();
            system("cls");  
            getqustion1();
            return;
        }
    }
    yang_setClor(7);  
    printf("\n按任意键继续游戏...");
    _getch();  
}
/*
* 负责人：小快
* 功能：实现游戏问答界面
* 详细逻辑：在玩家移动到答题道具上时，调用该函数，实现游戏问答界面
* 游戏问答界面的规则：
* 1.打印问题
* 2.打印选项
* 3.用户输入答案
*/
void getquestion2()
{
    typedef struct
    {

        char gushiquestion[100];
        char gushioptionA[50];
        char gushioptionB[50];
        char gushioptionC[50];
        char gushioptionD[50];
        char gushianswer;

    }gushi;
    gushi questions[30] = {
        // 名著常识题（1-15）
    {
        "《红楼梦》的作者是谁？",
        "罗贯中", "曹雪芹", "吴承恩", "施耐庵",
        'B'
    },
    {
        "《西游记》中孙悟空的第一位师傅是谁？",
        "唐僧", "菩提老祖", "如来佛祖", "观音菩萨",
        'B'
    },
    {
        "《三国演义》中刘备的结义兄弟不包括谁？",
        "张飞", "赵云", "关羽", "无正确答案",
        'B'
    },
    {
        "《水浒传》中绰号'及时雨'的梁山首领是？",
        "李逵", "宋江", "武松", "鲁智深",
        'B'
    },
    {
        "《红楼梦》中，与贾宝玉有'木石前盟'的是？",
        "薛宝钗", "史湘云", "林黛玉", "王熙凤",
        'C'
    },
    {
        "《西游记》中，唐僧取经的起点是？",
        "洛阳", "长安", "开封", "南京",
        'B'
    },
    {
        "《三国演义》中，'草船借箭'的主人公是？",
        "周瑜", "曹操", "诸葛亮", "孙权",
        'C'
    },
    {
        "《水浒传》中，'景阳冈打虎'的英雄是？",
        "鲁智深", "武松", "林冲", "李逵",
        'B'
    },
    {
        "《红楼梦》中，管理贾府日常事务的'凤辣子'是？",
        "王夫人", "王熙凤", "邢夫人", "秦可卿",
        'B'
    },
    {
        "《西游记》中，孙悟空的金箍棒原是什么？",
        "擎天柱", "定海神针", "随心铁杆兵", "上古神铁",
        'B'
    },
    {
        "《三国演义》中，诸葛亮的妻子是？",
        "黄月英", "孙尚香", "甄宓", "蔡文姬",
        'A'
    },
    {
        "《水浒传》中，绰号'豹子头'的是？",
        "林冲", "鲁智深", "武松", "杨志",
        'A'
    },
    {
        "《红楼梦》中，林黛玉的父亲曾任什么官职？",
        "知府", "巡盐御史", "尚书", "将军",
        'B'
    },
    {
        "《西游记》中，猪八戒在天庭原任什么职位？",
        "卷帘大将", "天蓬元帅", "弼马温", "托塔李天王",
        'B'
    },
    {
        "《三国演义》中，'过五关斩六将'的是？",
        "张飞", "赵云", "关羽", "马超",
        'C'
    },

        // 古诗题（16-30）
        {
            "李白《静夜思》中，'床前明月光'的下一句是？",
            "举头望明月", "低头思故乡", "疑是地上霜", "明月照我还",
            'C'
        },
        {
            "孟浩然《春晓》中，'夜来风雨声'的下一句是？",
            "处处闻啼鸟", "花落知多少", "春眠不觉晓", "春风吹又生",
            'B'
        },
        {
            "李绅《悯农》中，'谁知盘中餐'的下一句是？",
            "粒粒皆辛苦", "汗滴禾下土", "锄禾日当午", "农夫犹饿死",
            'A'
        },
        {
            "王之涣《登鹳雀楼》中，'欲穷千里目'的下一句是？",
            "黄河入海流", "更上一层楼", "白日依山尽", "群山入画来",
            'B'
        },
        {
            "贺知章《咏柳》中，'碧玉妆成一树高'的下一句是？",
            "二月春风似剪刀", "万条垂下绿丝绦", "不知细叶谁裁出", "春风送暖入屠苏",
            'B'
        },
        {
            "白居易《赋得古原草送别》中，'野火烧不尽'的下一句是？",
            "春风吹又生", "离离原上草", "远芳侵古道", "一岁一枯荣",
            'A'
        },
        {
            "柳宗元《江雪》中，'孤舟蓑笠翁'的下一句是？",
            "独钓寒江雪", "千山鸟飞绝", "万径人踪灭", "寒江雪纷纷",
            'A'
        },
        {
            "王维《鹿柴》中，'返景入深林'的下一句是？",
            "复照青苔上", "空山不见人", "林深不知处", "但闻人语响",
            'A'
        },
        {
            "王昌龄《出塞》中，'秦时明月汉时关'的下一句是？",
            "但使龙城飞将在", "万里长征人未还", "不教胡马度阴山", "孤城遥望玉门关",
            'B'
        },
        {
            "杜牧《清明》中，'清明时节雨纷纷'的下一句是？",
            "借问酒家何处有", "路上行人欲断魂", "牧童遥指杏花村", "春风送暖入屠苏",
            'B'
        },
        {
            "骆宾王《咏鹅》中，'白毛浮绿水'的下一句是？",
            "红掌拨清波", "曲项向天歌", "鹅鹅鹅", "水中游自在",
            'A'
        },
        {
            "王安石《梅花》中，'遥知不是雪'的下一句是？",
            "为有暗香来", "墙角数枝梅", "凌寒独自开", "梅花扑鼻香",
            'A'
        },
        {
            "张继《枫桥夜泊》中，'月落乌啼霜满天'的下一句是？",
            "姑苏城外寒山寺", "江枫渔火对愁眠", "夜半钟声到客船", "孤舟漂泊异乡人",
            'B'
        },
        {
            "李白《望庐山瀑布》中，'飞流直下三千尺'的下一句是？",
            "疑是银河落九天", "日照香炉生紫烟", "遥看瀑布挂前川", "庐山秀色甲天下",
            'A'
        },
        {
            "孟浩然《宿建德江》中，'移舟泊烟渚'的下一句是？",
            "野旷天低树", "日暮客愁新", "江清月近人", "孤帆远影碧空尽",
            'B'
        }
    };
    int a = rand() % 30; // 随机选择一个问题
    system("cls");
    yang_setClor(14);
    printf("╔════════════════════════════╗\n");
    printf("║                            ║\n");
    printf("║          问答挑战          ║\n");
    printf("║                            ║\n");
    printf("╚════════════════════════════╝\n");
    yang_setClor(11);
    printf("╔════════════════════════════\n");
    yang_setClor(7);
    printf("║  请回答以下问题，获得钥匙  \n");
    printf("║                            \n");
    yang_setClor(10);
    printf("║  题目：%s          \n", questions[a].gushiquestion);
    printf("║   A:  %s                   \n", questions[a].gushioptionA);
    printf("║   B:  %s                    \n", questions[a].gushioptionB);
    printf("║   C:  %s                    \n", questions[a].gushioptionC);
    printf("║   D:  %s                    \n", questions[a].gushioptionD);
    yang_setClor(9);
    printf("║  提示：输入大写字母后按回车    \n");
    printf("║  答对获得钥匙，答错可重试  \n");
    yang_setClor(11);
    printf("╚════════════════════════════\n\n");
    char answer;
    while (1) {
        yang_setClor(15);
        printf("请输入答案：");

        if (scanf_s("%c", &answer) != 1) {
            yang_setClor(12);
            printf("输入错误！请输入字母A-D\n");
            continue;
        }
        if (answer >= 'a' && answer <= 'd') {
            answer -= 32;
        }
        if (answer < 'A' || answer > 'D') {
            yang_setClor(12);
            printf("输入无效！请输入A-D之间的字母\n");
            continue;
        }

        if (answer == questions[a].gushianswer) {
            yang_setClor(10);
            printf("\n╔════════════════════════════╗\n");
            printf("║  回答正确！获得钥匙啦～    ║\n");
            printf("╚════════════════════════════╝\n");
            key++;
            break;
        }
        else {
            yang_setClor(12);
            printf("\n╔════════════════════════════╗\n");
            printf("║  回答错误！再试一次吧～    ║\n");
            printf("║       按 任意键 重试      ║\n");
            printf("╚════════════════════════════╝\n");
            _getch();
            system("cls");
            yang_setClor(14);
            printf("╔════════════════════════════╗\n");
            printf("║                            ║\n");
            printf("║          问答挑战          ║\n");
            printf("║                            ║\n");
            printf("╚════════════════════════════╝\n");

            yang_setClor(11);
            printf("╔════════════════════════════\n");

            yang_setClor(7);
            printf("║  请回答以下问题，获得钥匙  \n");
            printf("║                            \n");

            yang_setClor(10);
            printf("║  题目：%s          \n", questions[a].gushiquestion);
            printf("║   A:  %s                   \n", questions[a].gushioptionA);
            printf("║   B:  %s                    \n", questions[a].gushioptionB);
            printf("║   C:  %s                    \n", questions[a].gushioptionC);
            printf("║   D:  %s                    \n", questions[a].gushioptionD);
            yang_setClor(9);
            printf("║  提示：输入字母后按回车（不分大小写）\n");
            printf("║  答对获得钥匙，答错可重试  \n");

            yang_setClor(11);
            printf("╚════════════════════════════\n\n");
        }
    }

    yang_setClor(7);
    printf("\n按任意键继续游戏...");
    _getch();
}

//-----------------------------------------------------service----------------------------------------------------------
//---------------------------------------------------main ------------------------------------------------------------
int main()
{
    srand((unsigned int)time(NULL));
    const char* songs[] = { "./BGM1.mp3","./BGM2.mp3","./BGM3.mp3" };
    int songCount = sizeof(songs) / sizeof(songs[0]);
    srand((unsigned int)time(NULL));
    while (1) {
        int playlist[3] = { -1, -1, -1 };
        for (int i = 0; i < 3; i++) {
            int candidate;
            do {
                candidate = rand() % songCount;
                int duplicate = 0;
                for (int j = 0; j < i; j++) {
                    if (playlist[j] == candidate) {
                        duplicate = 1;
                        break;
                    }
                }
                if (!duplicate) break;
            } while (1);
            playlist[i] = candidate;
        }
        for (int i = 0; i < 3; i++) {
            int idx = playlist[i];
            char cmd[512];
            mciSendString("close myPlayer", NULL, 0, NULL);
            sprintf_s(cmd, sizeof(cmd), "open \"%s\" alias myPlayer", songs[idx]);
            mciSendString(cmd, NULL, 0, NULL);
            mciSendString("play myPlayer", NULL, 0, NULL);
        }
        break;
    }
    menuView();
    return 0;
}
    
//-----------------------------------------------------main ------------------------------------------------------------
 